
local ranks = {}
    ranks[1] = {name = 'Moderator', hex = '#00ff0d', color = {0, 255, 13}}
    ranks[2] = {name = 'Super Moderator', hex = '#008cff', color = {0, 140, 255}}
    ranks[3] = {name = 'Administrator', hex = '#ff0000', color = {255, 0, 0}}
    ranks[4] = {name = 'Manager', hex = '#b30000', color = {180, 0, 0}}


local owners = {}
    owners['508A52AA1DA1FF5FCC5C344CAC3812A1'] = true


local last = {}
last.dutyTry = {}
last.fix = {}
last.report = {}
last.vth = {}
last.vtt = {}
last.tt = {}
last.th = {}
last.fuel = {}

local admins = {}

function getAdmin(player, level)
    if not player or not level then return false end 
    return (getElementData(player, 'player:data').admin and getElementData(player, 'player:data').admin >= level and admins and admins[player] and admins[player] >= level)
end

function setPlayerAdmin(player, level)
    if not player or not level then return false end 
    local data = getElementData(player,"player:data")
    data.admin = level
    setElementData(player, 'player:data', data)
    admins[player] = level
    return true 
end

function leavePlayerFromDuty(player)
    local data = getElementData(player,"player:data")
    data.admin = false
    setElementData(player, 'player:data', data)
    if admins and admins[player] then admins[player] = nil end 
    return true 
end 

function acMessage(author, text)
    for i,v in pairs(admins) do 
        if i and isElement(i) and getElementData(i, 'player:data').uid then 
            outputChatBox('#ff2828[AC] #ffffff'..getPlayerName(author)..'['..getElementData(author,"id")..']: #fa9596'..text, i, 255, 255, 255, true)
        end
    end
end

function dutyAdmin(player, cmd)
    if not player then return false end 
    local serial = getPlayerSerial(player)
    local uid = getElementData(player, 'player:data').uid
    if not uid then return false end 
    if not getAdmin(player, 1) then 
        if last.dutyTry[player] and last.dutyTry[player] >= getTickCount()-5000 then exports['cmta-notyfikacje']:sendNotification(player,"#ccc000Informacja\n#ffffffPoczekaj chwilę...","info",3000) return end 
        local q = exports['cmta-db']:dbGet('SELECT * FROM cmta_admins WHERE uid=? AND serial=? LIMIT 1', uid, serial)
        last.dutyTry[player] = getTickCount()
        if q and #q > 0 then
            local q = q[1]
            triggerClientEvent('cmta_admin:updateReports', root, reports)
            triggerClientEvent(player, 'cmta_admin:openInterface', player)
            exports['cmta-notyfikacje']:sendNotification(player,"#ccc000Sukces!\n#ffffffZalogowałeś się na służbę.","success",2000)
            setPlayerAdmin(player, q.level or 1)
            return true 
        end
    else
        leavePlayerFromDuty(player)
        triggerClientEvent(player, 'cmta_admin:closeInterface', player)
        exports['cmta-notyfikacje']:sendNotification(player,"#ccc000Sukces!\n#ffffffWylogowałeś się ze służby.","success",2000)
        return true 
    end
end
addCommandHandler('duty', dutyAdmin)

function adminChat(player, cmd, ...)    
    local text = table.concat({...}, ' ')
    if not text or #text <= 0 then return false end 
    if getElementData(player, 'player:data').uid then 
        if admins then 
            acMessage(player, text, i)
        end
    end
end
addCommandHandler('ac', adminChat)
addCommandHandler('e', adminChat)


function findPlayerReport(player)
    if not player then return false end 
    if reports then 
        for i,v in ipairs(reports) do 
            if v.author == player then 
                return v 
            end
        end
    end
end
 
local reports = {}
function report(player, cmd, target, ...)
    if not last.report[player] or last.report[player] <= getTickCount()-60000 then 
        if not target then noti(player, 'Poprawne użycie komendy: /report <id/nick gracza> <powod>', 'info') return end 
        local target = exports['umta_utils']:findPlayer(target)
        if not target then noti(player, 'Nie odnaleziono podanego gracza', 'info') return end 
        if not ... then noti(player, 'Poprawne użycie komendy: /report <id/nick gracza> <powod>', 'info') return end 
        if findPlayerReport(player) then noti(player, 'Już wysłałeś jedno zgłoszenie!', 'fail') return end 
        local reason = table.concat({...}, ' ')
        reports[#reports+1] = {author = player, target = target, reason = reason}
        for i,v in pairs(getElementsByType("player")) do
            if getElementData(v,"player:data").admin then
                triggerClientEvent(v,'cmta_admin:newReport',v,reports)
            end
        end
        noti(player, 'Pomyślnie wysłano zgłoszenie', 'success')
        last.report[player] = getTickCount()
    else
        noti(player, 'Zgłoszenia możesz wysyłać co 60 sekund!', 'fail')
        return
    end
end
addCommandHandler('report', report)

function acceptRaport(id)
    local player = client
    if not player then return end 
    if not id or not tonumber(id) then return end 
    if not reports or not reports[tonumber(id)] then noti(player, 'Nieodnaleziono reporta o takim id (s-side)', 'info') return end 
    local author =  reports[id].author 
    if author then noti(author, 'Administrator '..exports['umta_utils']:removeHex(getPlayerName(player))..' przyjął Twojego reporta!') end 
    noti(player, 'Zaakceptowałeś zgłoszenie #'..id, 'info')
    acMessage(player, 'zaakceptował zgłoszenie #'..id)
    log(player, 'ar', id)
    reports[id] = nil 
    triggerClientEvent('cmta_admin:updateReports', root, reports)
end
addEvent('umta_sadm:acceptRaport', true)
addEventHandler('umta_sadm:acceptRaport', root, acceptRaport)

function declineReport(id)
    local player = client
    if not player then return end 
    if not id or not tonumber(id) then return end 
    if not reports or not reports[tonumber(id)] then noti(player, 'Nieodnaleziono reporta o takim id (s-side)', 'info') return end 
    local author =  reports[id].author 
    if author then noti(author, 'Administrator '..exports['umta_utils']:removeHex(getPlayerName(player))..' odrzucił Twojego reporta!') end 
    noti(player, 'Odrzuciłeś zgłoszenie #'..id, 'info')
    acMessage(player, 'odrzucił zgłoszenie #'..id, i)
    log(player, 'or', id)
    reports[tonumber(id)] = nil 
end
addEvent('umta_sadm:declineReport', true)
addEventHandler('umta_sadm:declineReport', root, declineReport)

-- KOMENDY --

function tpToPlayer(player, cmd, id)
    if not last.tt[player] or last.tt[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 1) then return end
        if not id then outputChatBox('#FF3333[DUTY]#FFFFFF Poprawne użycie: /tt <NICK/ID>',player,255,255,255,true) return end 
		local target=exports["cmta-core"]:findPlayer(player,id)
		if not target then
			outputChatBox("#FF3333[DUTY]#FF0000 Nie odnaleziono takiego gracza.", player, 255, 0, 0,true)
			return
		end
        if isPedInVehicle(player) then
			removePedFromVehicle(player)
		end
        local x,y,z = getElementPosition(target)
        setElementPosition(player, x+0.4, y, z) 
        setElementInterior(player,getElementInterior(target))
		setElementDimension(player,getElementDimension(target))   
        last.tt[player] = getTickCount()
    end
end
addCommandHandler('tt', tpToPlayer)

function tpPlayer(player, cmd, id)
    if not last.tt[player] or last.tt[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 1) then return end
        if not id then outputChatBox('#FF3333[DUTY]#FFFFFF Poprawne użycie: /th <NICK/ID>',player,255,255,255,true) return end 
        local target=exports["cmta-core"]:findPlayer(player,id)
		if not target then
			outputChatBox("#FF3333[DUTY]#FF0000 Nie odnaleziono takiego gracza.", player, 255, 0, 0,true)
			return
		end
        local x,y,z = getElementPosition(player)
        setElementInterior(target,getElementInterior(player))
		setElementDimension(target,getElementDimension(player))
        setElementPosition(target, x+0.4, y, z) 
        outputChatBox("#00ff00✦ "..ranks[getElementData(player,"player:data")["admin"]]["hex"]..""..ranks[getElementData(player,"player:data")["admin"]]["name"].." #ffffff"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."["..getElementData(player,"id").."] #ffffffprzeniósł Cię do siebie!", target, 255, 255, 255,true)
        last.th[player] = getTickCount()
    end
end
addCommandHandler('th', tpPlayer)

function warnPlayer(author, target, text)
    if not author or not target or not text then return end 
    local target=exports["cmta-core"]:findPlayer(author,target)
    if not target then
        outputChatBox("#FF3333[DUTY]#FF0000 Nie odnaleziono takiego gracza.", author, 255, 0, 0,true)
        return
    end
    triggerClientEvent(target,"cmta_admin:gui_warn",target,text,getPlayerName(author))
    exports["cmta-db"]:dbSet("insert into cmta_acts (type,reason,uid,admin) VALUES(?,?,?,?)", "ostrzeżenie", text, getElementData(target, "player:uid") ,getPlayerName(author):gsub("#%x%x%x%x%x%x",""))
    triggerClientEvent(root,"addNotifications",root,"#808080"..getPlayerName(target):gsub("#%x%x%x%x%x%x","").."[ID:"..getElementData(target,"id").."] otrzymał(a) ostrzeżenie za #ccc000"..text.." #808080[#ff0000od "..getPlayerName(author):gsub("#%x%x%x%x%x%x","").."#808080]")		
end

function warning(player, cmd, target, ...)
    if not getAdmin(player, 1) then return end 
    if not ... then return end 
    local text = table.concat({...}, ' ')
    if not target or not text then
        outputChatBox("#FF3333[DUTY]#FFFFFF Użycie: /warn <NICK/ID> <POWÓD>", player,255,255,255,true)
        return
    end
    warnPlayer(player, target, text)
end
addCommandHandler('warn', warning)


function kick(author, target, text)
    if not author or not target or not text then return end 
    local target=exports["cmta-core"]:findPlayer(author,target)
    if not target then
        outputChatBox("#FF3333[DUTY]#FF0000 Nie odnaleziono takiego gracza.", author, 255, 0, 0,true)
        return
    end
    if owners[getPlayerSerial(target)] then acMessage(author, '#ffff33⚠️ Nieudolnie próbowałem wyrzucić zarządce '..getPlayerName(target).." z serwera.") return end 
    local uid = getElementData(target, 'player:data').uid
    exports["cmta-db"]:dbSet("insert into cmta_acts (type,reason,uid,admin) VALUES(?,?,?,?)", "wyrzucenie", text, getElementData(target, "player:uid") ,getPlayerName(player):gsub("#%x%x%x%x%x%x",""))
	triggerClientEvent(root,"addNotifications",root,"#808080"..getPlayerName(target):gsub("#%x%x%x%x%x%x","").."[ID:"..getElementData(target,"id").."] został(a) wyrzucony(a) za #ccc000"..text.." #808080[#ff0000od "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."#808080]")		
    kickPlayer(target, author, text)
end

function k(player, cmd, target, ...)
    if not getAdmin(player, 1) then return end 
    if not ... then return end 
    local text = table.concat({...}, ' ')
    if not target or not text then
        outputChatBox("#FF3333[DUTY]#FFFFFF Użycie: /kick <NICK/ID> <POWÓD>", player,255,255,255,true)
        return
    end
    kick(player, target, text)
end
addCommandHandler('k', k)


































































































function findVehicle(id)
    for i,v in ipairs(getElementsByType('vehicle')) do 
        if getElementData(v, 'vehicle:data') and getElementData(v, 'vehicle:data').id == tonumber(id) then 
            return v 
        end
    end
end

function fix(player, cmd, id)
    if not last.fix[player] or last.fix[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 1) then return end
        if not id or not tonumber(id) then 
            local vehicle = getPedOccupiedVehicle(player)
            if vehicle then 
                fixVehicle(vehicle)
                noti(player, 'Nie podałeś id pojazdu, więc naprawiono pojazd, w którym siedzisz!', 'success')
                log(player, 'fix', 'pojazd, w ktorym siedzial')
            end 
            return 
        end
        local vehicle = findVehicle(tonumber(id))
        if vehicle then 
            noti(player, 'Naprawiono pojazd o id '..id, 'success')
            log(player, 'fix', id)
            fixVehicle(vehicle)
        end
        last.fix[player] = getTickCount()
    end
end
addCommandHandler('fix', fix)

function fixInRange(player, cmd, range)
    if not last.rangefix[player] or last.rangefix[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 2) then return end
        if not tonumber(range) or not range then noti(player, 'Poprawne użycie: /rangefix <dystans>') return end 
        local range = tonumber(range)
        if range > 100 then noti(player, 'Maksymalny dystans to 100!') return end 
        local x,y,z = getElementPosition(player)
        for i,v in ipairs(getElementsWithinRange(x, y, z, range or 15)) do 
            fixVehicle(v)
        end
        log(player, 'rangefix', 'pojazdy w dystansie '..range)
        noti(player, 'Naprawiono pojazdy!')
        last.rangefix[player] = getTickCount()
    end
end
addCommandHandler('rangefix', fixInRange)

function fuelVehicle(player, cmd, amount)
    if not last.fuel[player] or last.fuel[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 2) then return end
        if not tonumber(amount) or not amount then noti(player, 'Poprawne użycie: /fuel <ilosc>') return end 
        local amount = tonumber(amount)
        local vehicle = getPedOccupiedVehicle(player)
        if vehicle then 
            local data = getElementData(vehicle, 'vehicle:data')
            if data then 
                if tonumber(data.maxfuel) < tonumber(amount)+tonumber(data.fuel) then return end  
                data.fuel = data.fuel+tonumber(amount) 
                log(player, 'fuel', getElementData(vehicle, 'vehicle:data').id or 'respione')
                setElementData(vehicle, 'vehicle:data', data)
                noti(player, 'Pomyślnie zatankowano pojazd!')
            end
        end
        last.fuel[player] = getTickCount()
    end
end
addCommandHandler('fuel', fuelVehicle)

function tpVehicle(player, cmd, id)
    if not last.vth[player] or last.vth[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 1) then return end
        if not tonumber(id) or not id then noti(player, 'Poprawne użycie: /vth <id>') return end 
        local vehicle = findVehicle(id)
        if not vehicle then noti(player, 'Nieznaleziono pojazdu') return end 
        local x,y,z = getElementPosition(player)
        log(player, 'vth', getElementData(vehicle, 'vehicle:data').id or 'respione')
        setElementPosition(vehicle, x, y, z)    
        warpPedIntoVehicle(player, vehicle)
        last.vth[player] = getTickCount()
    end
end
addCommandHandler('vth', tpVehicle)
 
function tpToVehicle(player, cmd, id)
    if not last.vtt[player] or last.vtt[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 1) then return end
        if not tonumber(id) or not id then noti(player, 'Poprawne użycie: /vtt <id>') return end 
        local vehicle = findVehicle(id)
        if not vehicle then noti(player, 'Nieznaleziono pojazdu') return end 
        log(player, 'vtt', getElementData(vehicle, 'vehicle:data').id or 'respione')
        warpPedIntoVehicle(player, vehicle)
        last.vtt[player] = getTickCount()
    end
end
addCommandHandler('vtt', tpToVehicle)

 
function tpToVehicle(player, cmd, id)
    if not last.vtt[player] or last.vtt[player] <= getTickCount()-5000 then 
        if not getAdmin(player, 1) then return end
        if not tonumber(id) or not id then noti(player, 'Poprawne użycie: /vtt <id>') return end 
        local vehicle = findVehicle(id)
        if not vehicle then noti(player, 'Nieznaleziono pojazdu') return end 
        log(player, 'vtt', getElementData(vehicle, 'vehicle:data').id or 'respione')
        warpPedIntoVehicle(player, vehicle)
        last.vtt[player] = getTickCount()
    end
end
addCommandHandler('vtt', tpToVehicle)

--[[
    ban
]]--

function ban(author, target, text, hours)
    if not author or not target or not text then return end 
    local target = exports['umta_utils']:findPlayer(target)
    if not target then noti(author, 'Nieodnaleziono gracza', 'fail') return end 
    if owners[getPlayerSerial(target)] then acMessage(author, 'próbował zbanować właściciela '..getPlayerName(target)) return end 
    local uid = getElementData(target, 'player:uid')
    local q = exports['umta_db']:query('INSERT INTO bans(uid, nick, serial, expires, creator, reason) VALUES(?, ?, ?, NOW() + INTERVAL ? HOUR, ?, ?)', uid, exports['umta_utils']:removeHex(getPlayerName(target)), getPlayerSerial(target), hours,  exports['umta_utils']:removeHex(getPlayerName(author)), text)
    triggerClientEvent(root, 'umta_sadm:punishAlert', root, author, target, text..' ['..hours..' godz]', 'ban')
    log(author, 'ban', uid)
    kickPlayer(target, author, text)
end

function b(player, cmd, target, hours, ...)
    if not getAdmin(player, 2) then return end 
    if not hours or not tonumber(hours) or tonumber(hours) <= 0 then exports['umta_notifications']:sendNotification(player, 'Poprawne użycie: /b <target> <ilosc godzin> <text z minimum 5 znakami>', 'info') return end 
    if not ... then return end 
    local text = table.concat({...}, ' ')
    if not target or not text or #text < 5 then exports['umta_notifications']:sendNotification(player, 'Poprawne użycie: /b <target> <text z minimum 5 znakami> <ilosc godzin>', 'info') return end 
    ban(player, target, text, hours)
end
addCommandHandler('b', b)

addEventHandler('onPlayerConnect', root, function(nick, ip, username, serial)
    if serial then 
        local q = exports['umta_db']:wykonaj('SELECT * FROM bans WHERE serial=? AND expires > now()', serial)
        if q and #q > 0 then 
            local q = q[1]
            cancelEvent(true, 'Na Twój serial nałożony jest ban!\nBana nałożył: '..q.creator..'\nPowód bana: '..q.reason..'\nData zakończenia bana: '..q.expires)
        else
            exports['umta_db']:wykonaj('DELETE FROM bans WHERE serial=? AND expires < now()', serial) 
            return 
        end
    end 
end)

--[[
    mute
]]

function mute(author, target, text, r, amount)
    if not author or not target or not text or not r then return end 
    local target = exports['umta_utils']:findPlayer(target)
    if not target then noti(author, 'Nieodnaleziono gracza', 'fail') return end 
    --if owners[getPlayerSerial(target)] then acMessage(author, 'próbował zmutować właściciela '..getPlayerName(target)) return end 
    local uid = getElementData(target, 'player:uid')
    triggerClientEvent(root, 'umta_sadm:punishAlert', root, author, target, text..' ['..amount..' '..r..']', 'mute')
    local amount = r == 'd' and amount*86400 or r == 'm' and amount*60 or r == 'h' and amount*3600
    local expires = getRealTime().timestamp+amount
    local q = exports['umta_db']:query('INSERT INTO punish(type, target, creator, expires, serial, reason) VALUES(?, ?, ?, ?, ?, ?)', 'mute', getPlayerSerial(target), getElementData(author, 'player:uid'), expires, getPlayerSerial(target), text)
    log(author, 'mute', target)
    setElementData(target, 'player:mute', expires, false)
end

function m(player, cmd, target, amount, cat, ...)
    if not getAdmin(player, 1) then return end 
    if cat ~= 'd' and cat ~= 'h' and cat ~= 'm' then exports['umta_notifications']:sendNotification(player, '1Poprawne użycie: /m <target> <ilosc minut/godzin/dni> <D/M/H> <text z minimum 5 znakami>', 'info') return end 
    if not amount or not tonumber(amount) or tonumber(amount) <= 0 then exports['umta_notifications']:sendNotification(player, 'Poprawne użycie: /m <target> <ilosc minut/godzin/dni> <D/M/H> <text z minimum 5 znakami>', 'info') return end 
    local text = ... and table.concat({...}, ' ') or ''
    if not target or not text or #text < 5 then exports['umta_notifications']:sendNotification(player, 'Poprawne użycie: /m <target> <ilosc minut/godzin/dni> <D/M/H> <text z minimum 5 znakami>', 'info') return end 
    mute(player, target, text, cat, amount)
end
addCommandHandler('m', m)

--[[
    zpj
]]

function zpj(author, target, text, r, amount)
    if not getAdmin(author, 1) then return end 
    if not author or not target or not text or not r then return end 
    local target = exports['umta_utils']:findPlayer(target)
    if not target then noti(author, 'Nieodnaleziono gracza', 'fail') return end 
    --if owners[getPlayerSerial(target)] then acMessage(author, 'próbował zabrać prawo jazdy właściciela '..getPlayerName(target)) return end 
    local uid = getElementData(target, 'player:uid')
    triggerClientEvent(root, 'umta_sadm:punishAlert', root, author, target, text..' ['..amount..' '..r..']', 'zpj')
    local amount = r == 'd' and amount*86400 or r == 'm' and amount*60 or r == 'h' and amount*3600
    local expires = getRealTime().timestamp+amount
    local q = exports['umta_db']:query('INSERT INTO punish(type, target, creator, expires, serial, reason) VALUES(?, ?, ?, ?, ?, ?)', 'zpj', getPlayerSerial(target), getElementData(author, 'player:uid'), expires, getPlayerSerial(target), text)
    setElementData(target, 'player:zpj', expires, true)
    log(author, 'zpj', uid)
    if isPedInVehicle(target) then removePedFromVehicle(target) end 
end

function z(player, cmd, target, amount, cat, ...)
    if not getAdmin(player, 1) then return end 
    if cat ~= 'd' and cat ~= 'h' and cat ~= 'm' then exports['umta_notifications']:sendNotification(player, '1Poprawne użycie: /zpj <target> <ilosc minut/godzin/dni> <D/M/H> <text z minimum 5 znakami>', 'info') return end 
    if not amount or not tonumber(amount) or tonumber(amount) <= 0 then exports['umta_notifications']:sendNotification(player, 'Poprawne użycie: /zpj <target> <ilosc minut/godzin/dni> <D/M/H> <text z minimum 5 znakami>', 'info') return end 
    local text = ... and table.concat({...}, ' ') or ''
    if not target or not text or #text < 5 then exports['umta_notifications']:sendNotification(player, 'Poprawne użycie: /zpj <target> <ilosc minut/godzin/dni> <D/M/H> <text z minimum 5 znakami>', 'info') return end 
    zpj(player, target, text, cat, amount)
end
addCommandHandler('zpj', z)

--[[
    opj
]]

function opj(plr, cmd, target)
    if not getAdmin(plr, 2) then return end 
    if not target then exports['umta_notifications']:sendNotification(plr, 'Prawidlowe uzycie: /opj <target>', 'fail') return end 
    local target = exports['umta_utils']:findPlayer(target)
    if not target or not getElementData(target, 'player:zpj') then exports['umta_notifications']:sendNotification(plr, 'Nie znaleziono podanego gracza, lub nie ma zabranego prawka!', 'fail') return end 
    local uid = getElementData(target, 'player:uid')
    if not uid then return end 
    exports['umta_db']:query('DELETE FROM punish WHERE serial=? AND type=?', getPlayerSerial(plr), 'zpj')
    exports['umta_notifications']:sendNotification(target, exports['umta_utils']:removeHex(getPlayerName(plr))..' oddał Twoje prawo jazdy!', 'success')
    removeElementData(target, 'player:zpj')
    log(plr, 'opj', uid)
end
addCommandHandler('opj', opj)

--[[
    odcisz
]]

function odcisz(plr, cmd, target)
    if not getAdmin(plr, 2) then return end 
    if not target then exports['umta_notifications']:sendNotification(plr, 'Prawidlowe uzycie: /odcisz <target>', 'fail') return end 
    local target = exports['umta_utils']:findPlayer(target)
    if not target or not getElementData(target, 'player:mute') then exports['umta_notifications']:sendNotification(plr, 'Nie znaleziono podanego gracza, lub nie ma mute!', 'fail') return end 
    local uid = getElementData(target, 'player:uid')
    if not uid then return end 
    exports['umta_db']:query('DELETE FROM punish WHERE serial=? AND type=?', getPlayerSerial(plr), 'mute')
    exports['umta_notifications']:sendNotification(target, exports['umta_utils']:removeHex(getPlayerName(plr))..' usunął z Twojego konta karę wyciszenia!', 'success')
    removeElementData(target, 'player:mute')
    log(plr, 'odcisz', uid)
end
addCommandHandler('odcisz', odcisz)

--[[
    unban
]]

function unban(plr, cmd, target)
    if not getAdmin(plr, 2) then return end 
    if not target then exports['umta_notifications']:sendNotification(plr, 'Prawidlowe uzycie: /unban <serial>', 'fail') return end 
    exports['umta_notifications']:sendNotification(target, 'Pomyślnie usunięto bana z serialu '..target, 'success')
    exports['umta_db']:query('DELETE FROM bans WHERE serial=?', target)
    log(plr, 'unban', target)
end
addCommandHandler('unban', unban)

--[[
    komendy
]]--

--[[
    cars
]]

addCommandHandler('dodajpojazd', 
    function(plr, cmd, uid, name)
        if not getAdmin(plr, 4) then return end 
        if not uid or not name then exports['umta_notifications']:sendNotification(plr, 'Poprawne użycie: /dodajpojazd <uid> <nazwa>') return end 
        local id = getVehicleModelFromName(name)
        if not id then exports['umta_notifications']:sendNotification(plr, 'Taki pojazd nie istnieje!') return end 
        local q = exports['umta_db']:query('INSERT INTO vehicles(owner, model) VALUES(?, ?)', uid, id)
        if q then exports['umta_notifications']:sendNotification(plr, 'Pomyślnie dodano pojazd na konto #'..uid) end 

    end
)

--[[
    log
]]

function log(player, command, target)
    if not player or not command then return end 
    exports['umta_db']:query('INSERT INTO admin_logs(admin, command, target, date, serial) VALUES(?, ?, ?, now(), ?)', getElementData(player, 'player:uid'), command or 'error', target, getPlayerSerial(player))
end

